#!/usr/bin/python
# -*-coding: UTF-8 -*-
"""
# Time: 2024/5/10 18:53
# @Author: 修养
# @Project_name: PROJECT_NAME
"""
# names = "毛泽东, 周恩来, 朱德"
# names_list = names.split(",")
# print("按逗号分隔转为List: ", names_list)
# new_names = names.replace('朱德', '彭德怀')
# print("替换字符中元素：", new_names)  # 注意：该方法不修改原串，只会返回一个新串
names = "周恩来, 毛泽东, 陈独秀"
strToLsit = names.split(",")
print("字符串按逗号分割，转列表：", strToLsit)
new_names = names.replace("陈独秀", "朱德")
print("替换字符串中个别元素：", new_names)

# old = ' 12, 21, 22 '
# print("源字符串：", old)
# new_old = old.strip()
# print("剔除首尾空格：", new_old)
number = ' 1, 3, 4, 5 '

# str_s = "I like read the books!"
# print("原始字符串：", str_s)
# print("统计字符串中k的个数：", str_s.count('k'))
# print("查找like，找到多个时，返回第一次出现的下标，未找到返回-1：", str_s.find('like'))
# print("查找like，找到多个时，返回第一次出现的下标，未找到抛出异常：", str_s.index('like'))

# str_s = "UserPassword"
# print("字符串以特定字符开头，是返回True, 否返回False: ", str_s.startswith("User"))
# print("字符串以特定字符结尾，是返回True, 否返回False: ", str_s.endswith("Password"))

# names = ["毛泽东", "周恩来", "朱德"]
# print("将列表中多个字符串进行连接，并在相邻字符之间插入特定字符：", "和".join(names))

# str_s = "HelloWorld"
# print("字符串大小写互换：", str_s.swapcase())
# print("判断字符串是否为全大写：", str_s.isupper())
# print("判断字符串是否为全小写：", str_s.islower())
# print("去掉字符串中的空格：", str_s.replace(" ", ""))

# str_s = "我叫{},我今年{}岁了！"
# print("字符串格式化：", str_s.format("小明", 16))



